<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        /* 容器 */
        .main {
            margin: 10%;
            border: 2px solid red;
            border-radius: 10px;
            width: 800px;
            padding: 15px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
            align-items: left;
            justify-content: center;
        }

        .form-input .form-label {
            font-size: 16px;
            position: absolute;
            left:2px;
            bottom:10px;
        }

        .form-input {
            margin-top: 20px;
            width: 100%;
            position: relative;
        }

        .form-input input {
            width: 100%;
            border: 0;
            outline: none;
            border-bottom: 1px black solid;
        }

        .form-input input:focus {
            border: 0;
            border-bottom: 1px blue solid;
        }

        .form-input input:focus~label,
        .form-input input:valid~label{
            color: green;
            font-size: 12px;
            margin-bottom: 10px;
        }
    </style>
</head>

<body>
    <div class="main">
        <form>
            <div class="form-group">
                <h2>登录</h1>
                    <div class="form-input">
                        <input type="text" required>
                        <label class="form-label">学号*</label>
                    </div>
            </div>

            <div class="form-group">
                <div class="form-input">
                    <input type="password" required>
                    <label class="form-label">密码*</label>
                </div>
            </div>
        </form>
    </div>
</body>

</html>